<?php
class BaseDateModel extends CActiveRecord{
    protected function beforeSave(){
        if ($this->isNewRecord){//new record
            $this->createdDate = $this->updatedDate =  new CDbExpression('NOW()');
        }
        else
             $this->updatedDate =  new CDbExpression('NOW()');
        return parent::beforeSave();
    }
    
    protected function afterSave() {
        //prevent setFlash when alter User model each request
        if (strcasecmp(get_class($this), "User") != 0)
            Yii::app()->user->setFlash('success', 'Successfully save/alter record - ID: ' . $this->primaryKey );
        
        return parent::afterSave();
    }
}
?>
